package com.wuzhipeng.heart.user.dao.mapper;

import cn.hutool.core.date.DateTime;
import com.wuzhipeng.heart.user.dao.entity.Appointments;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wuzhipeng.heart.user.dto.request.TherapistAvailableTimeDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wuzhipeng
 * @since 2024-12-25
 */
public interface AppointmentsMapper extends BaseMapper<Appointments> {

    @Select("select * from appointments where ConsultantPhone= #{therapistPhone} and ConsultationDate = #{date} and ConsultationStatus=0 ")
    List<Appointments> selectByDate(TherapistAvailableTimeDTO therapistAvailableTimeDTO);

    @Select("SELECT * FROM appointments WHERE YEARWEEK(DATE_FORMAT(ConsultationDate,'%Y-%m-%d')) = YEARWEEK(NOW())")
    List<Appointments> selectWeekCount(String phone);

    @Select("SELECT * FROM appointments WHERE TO_DAYS(ConsultationDate) = TO_DAYS(NOW()) and ConsultantPhone=#{phone}")
    List<Appointments> selectTodayAppointments(String phone);

    @Select("SELECT * FROM appointments WHERE ConsultationDate  >= #{startDate} and ConsultantPhone = #{phone}")
    List<Appointments> selectSchedule(@Param("phone") String phone,@Param("startDate") DateTime startDate);
}
